package handler

import (
	"oct16-homework/model"
	"strconv"

	"github.com/gin-gonic/gin"
)

// 挂科列表

func List(c *gin.Context) {
	page, _ := strconv.Atoi(c.Query("page"))
	size, _ := strconv.Atoi(c.Query("size"))
	offset := (page - 1) * size

	var mark []model.Mark
	model.DB.Offset(offset).Limit(size).Debug().Find(&mark)

	var total int64
	model.DB.Model(&mark).Count(&total)

	c.JSON(200, gin.H{
		"code":  200,
		"msg":   "列表获取成功",
		"data":  mark,
		"total": total,
	})
}
